home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / ddj0897.zip / DYN401.ZIP / class / setseq.c < prev    next >
C/C++ Source or Header  |  1997-04-16  |  2KB  |  107 lines

  1.  
  2.  
  3. /*  Copyright (c) 1993-1996 Algorithms Corporation  */
  4. /*  All rights reserved.  */
  5.  
  6.  
  7.  
  8.  
  9. /*  This file automatically generated by dpp - do not edit  */
  10.  
  11. #define    DPP_STRATEGY    2
  12. #define    DPP_FASTWIDE    0
  13.  
  14.  
  15.  
  16. #line 17 "setseq.d"
  17. #include "set1.h" 
  18.  
  19. #define    CLASS    SetSequence_c
  20. #define    ivType    SetSequence_iv_t
  21.  
  22. #include "generics.h"
  23.  
  24. object    SetSequence_c;
  25.  
  26.  
  27. #line 28 "setseq.c"
  28. typedef struct  _SetSequence_iv_t  {
  29.     int iTabidx;
  30.     int iSize;
  31.     NODE * iTab;
  32.     NODE iCurrent;
  33. }    SetSequence_iv_t;
  34.  
  35.  
  36.  
  37. #line 27 "setseq.d"
  38. cmeth objrtn SetSequence_cm_gNewSetSeq(object self, int size, int nelm, void *tab)
  39.     object seq = oSuper(SetSequence_c, gNew, self)(self); 
  40.     ivType *iv = ivPtr(seq); 
  41.     iv->iSize = size; 
  42.     iv->iTab = (NODE *) tab; 
  43.     if (nelm) { 
  44.         for (; !iv->iTab[iv->iTabidx] ; ++iv->iTabidx); 
  45.         iv->iCurrent = iv->iTab[iv->iTabidx]; 
  46.     } 
  47.     return seq; 
  48.  
  49. imeth objrtn SetSequence_im_gNext(object self)
  50. { SetSequence_iv_t *iv = GetIVs(SetSequence, self);
  51.     NODE n; 
  52.     if (n = iv->iCurrent) { 
  53.         if (!(iv->iCurrent = iv->iCurrent->next)) 
  54.             while (++iv->iTabidx < iv->iSize) 
  55.             if (iv->iTab[iv->iTabidx]) { 
  56.             iv->iCurrent = iv->iTab[iv->iTabidx]; 
  57.             break; 
  58.         } 
  59.         return n->luk; 
  60.     } 
  61.     return gDispose(self); 
  62.  
  63.  
  64. #line 68 "setseq.c"
  65.  
  66. objrtn    SetSequence_initialize(void)
  67. {
  68.     static  CRITICALSECTION  cs;
  69.     static  int volatile once = 0;
  70.  
  71.     ENTERCRITICALSECTION(_CI_CS_);
  72.     if (!once) {
  73.         INITIALIZECRITICALSECTION(cs);
  74.         once = 1;
  75.     }
  76.     LEAVECRITICALSECTION(_CI_CS_);
  77.  
  78.     ENTERCRITICALSECTION(cs);
  79.  
  80.     if (SetSequence_c) {
  81.         LEAVECRITICALSECTION(cs);
  82.         return SetSequence_c;
  83.     }
  84.     INHIBIT_THREADER;
  85.     Sequence_initialize();
  86.     if (SetSequence_c)  {
  87.         ENABLE_THREADER;
  88.         LEAVECRITICALSECTION(cs);
  89.         return SetSequence_c;
  90.     }
  91.     SetSequence_c = gNewClass(Class, "SetSequence", sizeof(SetSequence_iv_t), 0, Sequence, END);
  92.     cMethodFor(SetSequence, gNewSetSeq, SetSequence_cm_gNewSetSeq);
  93.     iMethodFor(SetSequence, gNext, SetSequence_im_gNext);
  94.  
  95.     ENABLE_THREADER;
  96.  
  97.     LEAVECRITICALSECTION(cs);
  98.  
  99.     return SetSequence_c;
  100. }
  101.  
  102.  
  103.  
  104.